const dayjs = require("dayjs");
const db = require('../../middleware/db'); 
const Sequelize = require('sequelize');

module.exports = db.define('pro_product', {
    
        title:{
            comment:'标题',
            type: Sequelize.STRING(50),  
            allowNull: false,
            defaultValue: ''
            
         },
     
        content:{
            comment:'内容',
            type: Sequelize.TEXT(), 
            allowNull: false,
            defaultValue: ''
            
         },
     
        sort:{
            comment:'排序',
            type: Sequelize.INTEGER(11),  
            allowNull: false,
            defaultValue: '0'
         },
     
        release_date:{
            comment:'发布时间',
            type: Sequelize.DATE(), 
            allowNull: false,
            defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
            get() { return dayjs(this.getDataValue("release_date")).format("YYYY-MM-DD HH:mm:ss");}
         },
     
        is_publish:{
            comment:'是否发布',
            type: Sequelize.INTEGER(2),  
            allowNull: false,
            defaultValue: '0'
         },
     
        type_id:{
            comment:'产品类别',
            type: Sequelize.STRING(50),  
            allowNull: false,
            defaultValue: ''
            
         },
     
        list_pic:{
            comment:'列表图片',
            type: Sequelize.TEXT(), 
            allowNull: false,
            defaultValue: ''
            
         },
     
});